#include <random>

#include "particle.h"

Particle::Particle(float x, float y)
{
	vec.setX(x);
	vec.setY(y);
}

void Particle::RandMove()
{
	vec.setX(vec.x() - 1);
	std::random_device rd;
	std::mt19937 gen(rd());
	std::uniform_int_distribution<> distrib(-R, R);
	vec.setY(vec.y() + 1.0 * distrib(gen));
}

bool Particle::Intersects(const std::vector<Particle>& v) const
{
	for (const Particle& p : v)
	{
		if(p.vec.distanceToPoint(vec) < R)
		{
			return true;
		}
	}
	return  false;
}

bool Particle::Finished()
{
	return vec.x() < 1.0;
}
